package cn.stronglink.assetmanage.business.setting;

import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.View;

import butterknife.BindView;
import cn.stronglink.assetmanage.BaseActivity;
import cn.stronglink.assetmanage.MyApplication;
import cn.stronglink.assetmanage.R;

public class SettingActivity extends BaseActivity {
    TabLayout tbSetting;
    ViewPager vpSetting;
    private SystemViewPagerAdapter vpAdapter;
    private FragmentManager fm;
    private String[] mTitle = MyApplication.APP_CONTEXT.getResources().getStringArray(R.array.setting);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        setSelectPosition(7);
        initViewAndData();
    }

    private void initViewAndData() {
        initView();
        fm = getSupportFragmentManager();
        vpAdapter = new SystemViewPagerAdapter(fm, mTitle);
        vpSetting.setAdapter(vpAdapter);
        tbSetting.setupWithViewPager(vpSetting);
        tbSetting.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                vpSetting.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    private void initView() {
        tbSetting = findViewById(R.id.tb_setting);
        vpSetting = findViewById(R.id.vp_setting);
    }

    @Override
    public void onBackPressed() {

    }

}
